<!--
  ~ Copyright (c) 2020 the original author or authors
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      https://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  ~ or implied. See the License for the specific language governing
  ~ permissions and limitations under the License.
  -->

<h1 mat-dialog-title>{{'org_users.delete_dialog.title' | translate: {type: data.entityType} }}</h1>
<div mat-dialog-content>
  <ng-container [ngSwitch]="data.entityType.toLowerCase()">
    <ng-container *ngSwitchCase="'user'">
      <p *ngIf="!data.isSystemUser; else notFromSystem">{{'app_users.delete_dialog.confirmation_question' | translate :
        {name: data.entityName, application: data.organizationName || data.applicationName} }}
      </p>
      <ng-template #notFromSystem>
        <ng-container *ngIf="data.entity.ownerOfApplications.length > 0">
          <p>{{'org_users.delete_dialog.warn_information' | translate :
            {firstName: data.entity.firstName, lastName: data.entity.lastName} }}
            <strong>{{data.entity.ownerOfApplications.join(', ')}}</strong>.
          </p>
          <p>{{'org_users.delete_dialog.warn_hint_anyway' | translate}}
            <ng-container *ngIf="data.isOrganizationOwner; else userListText" >
              {{'org_users.delete_dialog.warn_hint_owner' | translate}}
            </ng-container>
            <ng-template #userListText>
              {{'org_users.delete_dialog.warn_hint_new_owner' | translate}}
              <mat-radio-group
                aria-labelledby="delete-radio-group"
                class="delete-radio-group"
                [(ngModel)]="data.seletedOption">
                <mat-radio-button
                  class="delete-radio-button"
                  *ngFor="let option of data.options"
                  [value]="option.value">
                  {{option.name}}
                </mat-radio-button>
              </mat-radio-group>
            </ng-template>
          </p>
        </ng-container>

        <ng-container *ngIf="data.entity.ownerOfApplications.length === 0">
          <p> {{'org_users.delete_dialog.confirmation_question' | translate:
            {name: data.entity.firstName, lastName: data.entity.lastName} }}</p>
        </ng-container>
      </ng-template>
    </ng-container>
    <ng-container *ngSwitchDefault>
      <p> {{'org_users.delete_dialog.default_confirmation' | translate:
        {type: data.entityType, name: data.entityName} }}
      </p>
    </ng-container>
  </ng-container>
</div>
<div mat-dialog-actions>
  <button class="button-cancel" mat-button [mat-dialog-close]="false">{{'common.capital.cancel' | translate}}</button>
  <button class="button-create" mat-button [mat-dialog-close]="true" cdkFocusInitial>{{'common.capital.yes' | translate}}</button>
</div>
